package org.bluedream.core.module.entity.stock;

import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.bluedream.comm.base.OrgPageEntity;
import org.bluedream.core.utils.UserUtil;

import java.math.BigDecimal;

/**
 * @ClassName TmpSkuStock
 * @Description TODO
 * @Author Administrator
 * @Data 2022/7/1 9:28
 * @Version
 */
@Data
@ToString(callSuper = true)
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
@TableName(value = "tmpSkuStock")
public class TmpSkuStock extends OrgPageEntity<TmpSkuStock> {
    private static final long serialVersionUID = 2389352802679358367L;
    private String billType;
    private Integer billTypeLabel;
    private String billNum;
    private BigDecimal qty;
    private BigDecimal oprice;
    private BigDecimal total;
    private BigDecimal sumQty;
    private BigDecimal sumTotal;
    private String code;
    private String warCode;

    public TmpSkuStock(String id, String billType, Integer billTypeLabel,String billNum, BigDecimal qty, BigDecimal total, String code, String warCode) {
        super(id);
        this.billType = billType;
        this.billTypeLabel = billTypeLabel;
        this.billNum = billNum;
        this.qty = qty;
        this.total = total;
        this.code = code;
        this.warCode = warCode;
        this.orgCode = UserUtil.getLoginOrgCode();
        if (total.compareTo(new BigDecimal("0")) == 0 || qty.compareTo(new BigDecimal("0"))== 0){
            this.oprice = new BigDecimal("0");
        }else {
            this.oprice = total.divide(qty);
        }
    }

    public TmpSkuStock(String orgCode, String warCode, String productCode){
        this.orgCode = orgCode;
        this.warCode = warCode;
        this.code = productCode;
        this.sumQty = new BigDecimal("0");
        this.sumTotal = new BigDecimal("0");
    }
}